package com.tool_stdy.concurrent;

import java.util.concurrent.LinkedBlockingQueue;

/**
 * Created by yan_li on 2016/1/28.
 */
public class Consummer {
    private static LinkedBlockingQueue que = new LinkedBlockingQueue();

    public static void main(String[] args) throws InterruptedException {
//        new Thread(new Runnable(){
//            @Override
//            public void run() {
//                for(int i=0;i<200;i++){
//                    try {
//                        //Thread.sleep(600);
//                        if(i==20){
//                            Thread.sleep(10000);
//                        }
//                        que.add(i);
//                        System.out.println("put"+i);
//                    } catch (InterruptedException e) {
//                        e.printStackTrace();
//                    }
//                }
//            }
//        }).start();
        que.add("1");
        que.add("2");
        new Thread(new Runnable(){
            @Override
            public void run() {
                for(int i=0;i<200;i++){
                    try {
                       // Thread.sleep(800);
                        System.out.println(">>>>Get:"+que.peek()+"---->"+que.size());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();

        Thread.sleep(200000000);
        System.out.println("over");
    }
}
